 /* 构建初始车型信息
 ** 后台不保存车型数据, 所以需要从订单中提取部分车型数据，进行拼接，模拟已选择车型数据
 */
import CarModel from '@/components/ivew_conf/car_model'
import carModel from './../../ivew_conf/car_model';
import loop from '@/utils/loop'

export default (ctx, next) =>{
    let resData  = ctx.params;
    let model:carModel = new CarModel();
    let map = {
        'DEVtonnages':'tonnages',  
        'DEVweight': 'weight',  
        'DEVseats': 'seats',  
        'DEVprice': 'price',
        'DEVengineCapacity': 'engineCapability',
        'DEVvehicleId': 'vehicleId',
        'DEVenergyType': 'energyType'

    };
    
    model = loop.assignment(resData, model, map, true) ;

    // 重新分配数据结构
    ctx.params = {
        orderData: resData,
        carModels: [model]
    }; 
    

    next()
}